(function () {

    'use strict';

    angular
    .module('app')
    .factory('ConfirmCartService', ConfirmCartService);

    ConfirmCartService.$inject = ['$http', '$q', '$timeout', '$rootScope'];

    function ConfirmCartService($http, $q, $timeout, $rootScope) {

        var service = {};

        service.goods = [];
        service.express = null;
        service.address = null;
        service.clear = _clear;
        service.input = {
            comment: ""
        };

        $rootScope.$on('consigneeChanged', function( event, res ) {
            service.address = res;
        });

        $rootScope.$on('expressChanged', function( event, res ) {
            service.express = res;
        });

        return service;

        function _clear() {
            this.goods = [];
            this.express = null;
            this.address = null;
            this.input = {
                score: 0,
                comment: ""
            };
        }
    }

})();
